package com.graduation.adminservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.po.Law;
import com.graduation.pojo.query.LawQuery;
import com.graduation.pojo.vo.LawVO;
import com.graduation.service.LawService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/law")
@RequiredArgsConstructor
public class LawController {

    private final LawService lawService;

    @GetMapping("/page")
    public PageDTO<LawVO> pageLaws(LawQuery query) {
        return lawService.pageLaws(query);
    }

    @GetMapping("/{id}")
    public Law getLawById(@PathVariable(name = "id") Long id) {
        return lawService.getLawById(id);
    }

    @PostMapping
    public void saveLaw(@RequestBody Law law) {
        lawService.saveLaw(law);
    }

    @PutMapping
    public void updateLaw(@RequestBody Law law) {
        lawService.updateLaw(law);
    }

    @DeleteMapping("/{id}")
    public void deleteLaw(@PathVariable(name = "id") Long id) {
        lawService.deleteLaw(id);
    }

}
